package export.magicWeapon
{
	import base.*;
	
	import com.game.data.vo.EquipmentVO;
	import com.greensock.*;
	
	import export.bullet.*;
	
	import flash.geom.*;
	
	public class MagicTimer extends BaseMagicWeapon
	{
		
		public function MagicTimer(param1:BaseHero)
		{
			super(param1);
		}
		
		public var wait:SpecialEffectBullet;
		private var premp:int;
		private var prehp:int;
		private var prex:Number;
		private var prey:Number;
		private var premagicweaponx:Number;
		private var premagicweapony:Number;
		
		override protected function initBBDC():void
		{
			var _loc1_:* = null;
			var _loc2_:Array = BaseBitmapDataPool.getBitmapDataArrayByName("MagicTimeBmd");
			if (_loc2_)
			{
				_loc1_ = {
					"name"  : "body",
					"source": _loc2_
				};
				bbdc = new BaseBitmapDataClip([_loc1_], 100, 100, new Point(0, 0));
				bbdc.setOffsetXY(-20, -10);
				bbdc.setFrameStopCount([[12, 12, 12, 12, 12, 12], [9999]]);
				bbdc.setFrameCount([6, 1]);
				bbdc.setAddScriptWhenFrameOver(scriptFrameOverFunc);
				this.addChild(bbdc);
				return;
			}
			throw new Error("MagicTime--BitmapData Error!");
		}
		
		override public function showSkill():void
		{
			var bb:SpecialEffectBullet;
			var equip:EquipmentVO = null;
			var cd:int = 30;
			this.prehp = this.sourceRole.getHp();
			this.premp = this.sourceRole.getMp();
			this.prex = this.sourceRole.x;
			this.prey = this.sourceRole.y;
			this.premagicweaponx = this.x;
			this.premagicweapony = this.y;
			bb = new SpecialEffectBullet("MagicTimeStartEffect");
			bb.x = this.x;
			bb.y = this.y;
			bb.setDisable();
			bb.setOwner(this.sourceRole);
			bb.setAction("idle");
			this.sourceRole.magicBulletArray.push(bb);
			gc.gameScene.addChild(bb);
			bb = new SpecialEffectBullet("MagicTimeStart");
			bb.x = this.x;
			bb.y = this.y;
			bb.setDisable();
			bb.setOwner(this.sourceRole);
			bb.setAction("idle");
			this.sourceRole.magicBulletArray.push(bb);
			gc.gameScene.addChild(bb);
			this.wait = new SpecialEffectBullet("MagicTimeWait");
			this.wait.x = this.x;
			this.wait.y = this.y;
			this.wait.setDisable();
			this.wait.setOwner(this.sourceRole);
			this.wait.setAction("idle");
			if (this.sourceRole.getPlayer())
			{
				equip = this.sourceRole.getPlayer().getCurEquipByType("zbfb");
				if (equip)
				{
					if (equip.getFiveElementString().indexOf("木") != -1)
					{
						cd = 27;
					}
				}
			}
			this.sourceRole.magicBulletArray.push(this.wait);
			gc.gameScene.addChild(this.wait);
			this.wait.setFuncWhenDestroy(this.returnpos);
			TweenMax.delayedCall(cd, function (param1:MagicTimer):*
			{
				param1.setAction("idle");
			}, [this]);
		}
		
		private function returnpos(param1:BaseBullet):*
		{
			var bb:SpecialEffectBullet = new SpecialEffectBullet("MagicTimeOver");
			bb.x = this.premagicweaponx;
			bb.y = this.premagicweapony;
			bb.setDisable();
			bb.setOwner(this.sourceRole);
			bb.setAction("idle");
			this.sourceRole.magicBulletArray.push(bb);
			gc.gameScene.addChild(bb);
			TweenMax.to(this.sourceRole, 1, {
				"x"         : this.prex,
				"y"         : this.prey,
				"onComplete": function ():*
				{
					sourceRole.getAttribute().hp = prehp;
					sourceRole.getAttribute().mp = premp;
				}
			});
			this.wait = null;
		}
	}
}
